gsk: Don't overflow vbo_count
authorMatthias Clasen <mclasen@redhat.com>
Mon, 28 Jun 2021 19:00:41 +0000 (15:00 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 28 Jun 2021 19:00:41 +0000 (15:00 -0400)
We use 16 bits to store vbo_count, so we can't create
batches that have more than 65535 vertices. Pay attention
to that limit when merging batches.

gsk/ngl/gsknglcommandqueue.c

index 6d61dbaad67699d8b2a87a9792417b56eafd8a8e..5449fde9af5b8ccfe0534b4cbfc58bf43fd8ddca 100644 (file)
@@ -617,6 +617,7 @@ gsk_ngl_command_queue_end_draw (GskNglCommandQueue *self)
       last_batch->any.viewport.height == batch->any.viewport.height &&
       last_batch->draw.framebuffer == batch->draw.framebuffer &&
       last_batch->draw.vbo_offset + last_batch->draw.vbo_count == batch->draw.vbo_offset &&
+      last_batch->draw.vbo_count + batch->draw.vbo_count < G_MAXINT16 &&
       snapshots_equal (self, last_batch, batch))
     {
       last_batch->draw.vbo_count += batch->draw.vbo_count;